import java.util.Scanner;
public class FactorialSum {
    public static int factorial(int n)//求n!的方法
    {
        if(n==1)
        {
            return 1;
        }

        return  n*factorial(n-1);
    }
    public static int Sum(int num)//求了n!再求阶乘和
    {
        if(num==1)
        {
            return 1;
        }
        return factorial(num)+Sum(num-1);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入要求到几的阶乘和：");
        int num=sc.nextInt();
        System.out.printf("1!+……+%d！的阶乘和是：%d",num,Sum(num));

    }
}
